import java.io.*;

public class Task {
    public static void main(String[] args)throws Exception{
        String sourceFilePath = "lesson9/task4/resource/meizi.jpg";
        String dstFilePath = "lesson9/task6/resource/meizi.jpg";
        new File(dstFilePath).getParentFile().mkdirs();
        
        copyFile(sourceFilePath, dstFilePath);
    }
    public static void copyFile(String sourceFilePath, String dstFilePath)  {

        // 1. 创建文件输入流
        InputStream is = new FileInputStream(sourceFilePath);
        // 2. 创建文件输出流
        OutputStream os = new FileOutputStream(dstFilePath);
        // 3. 创建buffer
        byte[] buffer = new byte[1024];
        int len = -1;
        // 4. 读取文件
        while ((len = is.read(buffer)) != -1) {
            // 5. 写入文件
            os.write(buffer, 0, len);
        }
        // 6. 关闭流
        is.close();
        os.close();

    }
}